import Taro from "@tarojs/taro";
import {View, Text, Image} from "@tarojs/components";
import "./feed.less";

export default class Feed extends Taro.Component {
  constructor() {
    super(...arguments);
  }

  componentWillMount() {
  }

  // 跳转详情页
  toNoteDetailPage() {
    Taro.navigateTo({
      url: `/pages/note-detail/note-detail?noteId=${this.props.note.id}&from=${
        this.props.from
        }`
    });
  }

  render() {
    return (
      <View className='note-container'>
        <View className='list-item has-img' onTap={this.toNoteDetailPage.bind(this)}>
          <View className="collector-info">
            <Text className="title">{this.props.note.title}</Text>
            <Text className="meta">
              {this.props.note.createdAt}
              <Text style="padding:0 5PX">·</Text>
              {this.props.note.readNum ? this.props.note.readNum : 0}浏览数
            </Text>
          </View>
          <View>
            {this.props.note.cover ? (
              <Image mode="aspectFill" src={this.props.note.cover}/>
            ) : (
              ""
            )}
          </View>
        </View>

      </View>
    );
  }
}
